<template>
  <div>
    <ol class="breadcrumb">
      <li><router-link to="/">首页</router-link></li>
      <li><a href="#">管理</a></li>
      <li class="active">学生管理</li>
    </ol>

    <button class="btn btn-success" @click="get">发送http请求-axios</button>
    <button class="btn btn-success" @click="add">添加</button>
    <button class="btn btn-success" @click="del">删除</button>
    <button class="btn btn-success" @click="upd">修改</button>



  </div>
</template>
<script>
export default {
  methods: {
    get(){
      //查询的
      this.$http.get("http://localhost:3000/majors")
      .then((rs)=>{
        console.log(rs);
      }).catch(err=>{
        console.log(err);
      })
    },
    add(){
      //添加
      this.$http.post("http://localhost:3000/student",{id:4,text:"通信专业",desc:"整网线,玩路由..."})
      .then( rs => {

        console.log(rs);
        if(rs.status == 201){
          this.$layer.msg("添加成功...")
        }
      })
    },
    del(){
      this.$http.delete("http://localhost:3000/majors/4").then(rs=>{
        if(rs.status === 200) this.$layer.msg("删除成功!")
      })
    },
    upd(){
      this.$http.put("majors/3",{text:"通信专业6666123",desc:"整网线,玩路由...666"})
      .then( rs => {
        console.log(rs);
        if(rs.status == 201){
          this.$layer.msg("添加成功...")
        }
      })
    }


  },
};
</script>
<style lang="less">
</style>